import java.util.Stack;

/**
 * @author: li_jian
 * @version: 1.0
 * @date: 2020/7/7 01:03
 * @description： @link{https://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?tpId=13&&tqId=11158&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking}
 */
public class JZ5_用两个栈实现队列 {

    Stack<Integer> in = new Stack<Integer>();
    Stack<Integer> out = new Stack<Integer>();

    public void push(int node) {
        in.push(node);
    }

    public int pop() {

        if (out.isEmpty()){
            while (!in.isEmpty()) {
                out.push(in.pop());
            }
        }

        if (!out.isEmpty()) {
            return out.pop();
        }
        throw new RuntimeException("栈空");
    }
}
